package com.cnzhy.service.fallback;

import com.cnzhy.entity.CrmAdminUser;
import com.cnzhy.service.UserFeignService;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * @Author: zhaoyan5
 */
@Component
@Slf4j
public class UserServiceFallbackFactory implements FallbackFactory<UserFeignService> {

    @Override
    public UserFeignService create(Throwable cause) {
        return new UserFeignService() {

            @Override
            public String getMessage(String name) {
                log.error("服务降流原因", cause);
                return "服务降流";
            }

            @Override
            public CrmAdminUser getCrmAdminUser(long userId) {
                log.error("服务降流原因", cause);
                return null;
            }
        };
    }
}
